using jSLCore.Client.Presentation.Authorization;
using jSLCore.Client.Presentation.jBinding;

namespace jSLApp.Client.Security
{
    /// <summary>
    /// Use it to bind controls to permissions
    /// </summary>
    public class SecurityBinding : jSecurityBinding
    {
        public SecurityBinding()
        {
        }

        public SecurityBinding(Permission permission) : base((int?) permission)
        {
        }

        public SecurityBinding(string elementPropertyPath, Permission permission) : base(elementPropertyPath, (int?) permission)
        {
            
        }

        public new Permission Permission
        {
            get
            {
                return (Permission)base.Permission.GetValueOrDefault(-1);
            }
            set
            {
                base.Permission = (int?)value;
            }
        }

        public static bool HasPermission(Permission permission)
        {
            return jSecurity.HasPermission((int)permission);
        }
    }
}